﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace NUnit.Framework
{
    static public class Assertions
    {
        #region Static public methods

        [DebuggerStepThrough]
        static public void AssertIsEqual<T>(this T actual, T expected)
        {
            Assert.AreEqual(expected, actual);
        }

        [DebuggerStepThrough]
        static public void AssertIsFalse(this bool value)
        {
            Assert.IsFalse(value);
        }

        [DebuggerStepThrough]
        static public void AssertIsNotNull(this object left)
        {
            Assert.IsNotNull(left);
        }

        [DebuggerStepThrough]
        static public void AssertIsNotSame<T>(this T actual, T expected)
            where T : class
        {
            Assert.AreNotSame(expected, actual);
        }

        [DebuggerStepThrough]
        static public void AssertIsNull(this object left)
        {
            Assert.IsNull(left);
        }

        [DebuggerStepThrough]
        static public void AssertIsSame<T>(this T actual, T expected)
            where T : class
        {
            Assert.AreSame(expected, actual);
        }

        [DebuggerStepThrough]
        static public void AssertIsTrue(this bool value)
        {
            Assert.IsTrue(value);
        }

        #endregion

        #region Collection assertions

        [DebuggerStepThrough]
        static public void AssertIsEmpty(this IEnumerable collection)
        {
            CollectionAssert.IsEmpty(collection);
        }

        [DebuggerStepThrough]
        static public void AssertSequenceEqual<T>(this IEnumerable<T> actual, params T[] expected)
        {
            CollectionAssert.AreEqual(expected, actual,
                                      "Actual sequence is wrong: {0}", actual.Select(x => x.ToString()).Join(", "));
        }

        [DebuggerStepThrough]
        static public void AssertSequenceEqual<T>(this IEnumerable<T> actual, IEnumerable<T> expected)
        {
            CollectionAssert.AreEqual(expected, actual,
                                      "Actual sequence is wrong: {0}", actual.Select(x => x.ToString()).Join(", "));
        }

        [DebuggerStepThrough]
        static public void AssertSetEqual<T>(this IEnumerable<T> actual, params T[] expected)
        {
            CollectionAssert.AreEquivalent(expected, actual);
        }

        [DebuggerStepThrough]
        static public void AssertSetEqual<T>(this IEnumerable<T> actual, IEnumerable<T> expected)
        {
            CollectionAssert.AreEquivalent(expected, actual);
        }

        #endregion
    }
}